package com.zb.framework.wechatnews.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebMvcConfigurer extends WebMvcConfigurerAdapter {

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {

		registry.addResourceHandler("/statics/**").addResourceLocations("classpath:/statics/");
		// 解决 SWAGGER 404报错
		registry.addResourceHandler("/swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
		registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");

		// 解决断路器监控图片看不了问题
		registry.addResourceHandler("/hystrix/**").addResourceLocations("classpath:/static/hystrix/");
	}

	/**
	 * 自动转换时间格式
	 *
	 * @param registry date
	 */
	@Override
	public void addFormatters(FormatterRegistry registry) {
		// registry.addFormatter(new DateFormatter("yyyy-MM-dd HH:mm:ss"));
		registry.addConverter(new DateConverterConfig());
	}

}
